﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ElfTyping.General;

namespace ElfTyping.States
{
    abstract public class State
    {
        State changeToState = null;
        bool shouldFade = false;

        abstract public void InitializeState();
        abstract public void Draw(Camera camera);
        abstract public void HandleInput(InputInfo inputInfo);

        // ALL subclasses of State need to call State's tick at the end of their tick.
        public virtual void Tick(float dt)
        {
            if (changeToState != null)
            {
                if (shouldFade)
                {
                    changeToState = new FadingState(this, changeToState);
                }

                TypingGame.Game().ChangeState(changeToState);
                changeToState = null;
            }
        }

        protected void ChangeStateAfterTick(State nextState, bool fade)
        {
            changeToState = nextState;
            shouldFade = fade;
        }
    }
}
